<?php
require COMMON_PATH . '/function.php';
class BaseAction extends Action {
    public function _initialize(){
		$this->menu = array(
			'index'			=>	array('监控图示', U('Main/index')),
			'log'			=>	array('日志', U('Main/log')),
			'import'		=>	array('手动导入数据', U('Main/importdata'), 'ajaxrequest'),
			'logout'		=>	array('退出', U('Index/logout')),
		);

		$this->currentMenu = 'index';

		/* 清除log */
		0 === mt_rand(0, 100) && D('log')->clearlog(30 * 24);	/* 1/100的概率 清除30天的日志 */

		if(PHP_SAPI !== 'cli' && (!$_COOKIE['password'] || $_COOKIE['password'] !== md5(C('password')))){
			redirect(U('Index/login') . '&redirect=' . urlencode($_SERVER['REQUEST_URI']));
		}

    }
}